﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;

using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using Autodesk.Revit.ApplicationServices;
using Autodesk.Revit.Attributes;
 
 
 
  

namespace ZhuXingFamilys.test
{
    [TransactionAttribute(Autodesk.Revit.Attributes.TransactionMode.Manual)]
    public class test : IExternalCommand
    {
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            UIDocument uiDoc = commandData.Application.ActiveUIDocument;
            Document doc = uiDoc.Document;

            FilteredElementCollector collector = new FilteredElementCollector(doc);
            IList<Element> views = collector.OfClass(typeof(ViewSchedule)).ToElements();

            string viewStr = null;
            foreach (Element ele in views)
            {
                ViewSchedule viewschedule = ele as ViewSchedule;
                if (viewschedule == null || viewschedule.IsTemplate)
                {
                    continue;
                }
                else
                {
                    ElementType objType = doc.GetElement(viewschedule.GetTypeId()) as ElementType;
                    if (null == objType || objType.Name.Equals("Schedule") || objType.Name.Equals("Drawing sheet"))
                    {
                        continue;
                    }
                    viewStr += viewschedule.Name + "\n";
                }
            }
            TaskDialog.Show("Infor", viewStr);

            return Result.Succeeded;

        }
    }
}
